﻿using System;
using System.ComponentModel;
using System.Diagnostics;
using System.Windows;
using MessageBox = Xceed.Wpf.Toolkit.MessageBox;

namespace Gao.Poker.ViewModel
{
    public class BaseViewModel : INotifyPropertyChanged
    {

        public event PropertyChangedEventHandler PropertyChanged;

        public virtual void OnPropertyChanged(string propertyName)
        {
            //VerifyPropertyName(propertyName);
            PropertyChangedEventHandler handler = PropertyChanged;
            if (handler != null) handler(this, new PropertyChangedEventArgs(propertyName));
        }

        [Conditional("DEBUG")]
        [DebuggerStepThrough]
        public void VerifyPropertyName(string propertyName)
        {
            if (TypeDescriptor.GetProperties(this)[propertyName] == null)
            {
                //string msg = "Invalid property name: " + propertyName;

                //if (this.ThrowOnInvalidPropertyName)
                //    throw new Exception(msg);
                //else
                //    Debug.Fail(msg);
            }
        }

        public void ShowMessage(String msg)
        {
            MessageBox.Show(msg, "提示消息", MessageBoxButton.OK, MessageBoxImage.Information);
        }

        public Action<String> Message { get; set; }
    }
}
